<template>
	<view>
		<uni-grid :column="3" :square="false">
			<uni-grid-item v-for="(item,i) in brandList" :key="i">
				<view class="brand" @click="showpProduct(i)">
					<uni-badge 
					:text="item.popularity" 
					type="error" absolute="rightTop"
					:offset="[4,-1]" :maxNum=99>
						<image mode="widthFix" :src="$url.base+item.logo"/>
					</uni-badge>
					<text>{{item.bname}}</text>
				</view>
			</uni-grid-item>
			
		</uni-grid>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				brandList: []
			}
		},
		onLoad(){
			uni.showLoading({
				title:'加载中'
			})
			let url=this.$url.brandList
			uni.request({
				url,
				success: (res) => {
					console.log(res.data)
					this.brandList=res.data
				},
				fail: (err) => {
					console.log(err)
				},
				complete: () => {
					uni.hideLoading()
				}
			})
		},
		methods: {
			showpProduct(i) {
				let bname=this.brandList[i].bname
				let kw=this.brandList[i].keywords
				uni.navigateTo({
					url:`../product-list/product-list?bname=${bname}&kw=${kw}`
				})
			}
		},
	}
		
</script>

<style lang="scss">
	.brand{
		display: flex;
		flex-direction: column;
		align-items: center;
		padding:$uni-spacing-col-lg 0;
		image{
			width:200rpx;
			
		}
	}
</style>
